<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    body {
      width: 100%;
      height: 100%;
    }
  </style>
</head>

<body>
  <img src="./图片/1.png">
  <img src="./图片/2.png">
  <button>切换</button>
  <script>
    var img = document.getElementsByTagName('img')
    console.log(img)
    for (var i = 0; i < img.length; i++) {
      img[i].onclick = function (e) {
        document.body.style.backgroundImage = `url(${e.target.src})`
      }
    }
  </script>
</body>



</html>